package com.ps.aop;

import java.util.Map;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.ps.actions.BaseAction;
import com.ps.actions.person.LoginAction;
import com.ps.global.Globals;
/**
 * 登录判断
 * @author Administrator
 *
 */
public class CheckLoginInterceptor extends AbstractInterceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = 707263824321765546L;

	@Override
	public String intercept(ActionInvocation arg0) throws Exception {

		Object actionObj = arg0.getAction();
		if (actionObj instanceof LoginAction) {
			return arg0.invoke();
		}
		Map<String, Object> session = arg0.getInvocationContext().getSession();		
		if (session.containsKey(Globals.SESSION_USER)) {
			return arg0.invoke();
		} else {
			return 	BaseAction.LOGIN;
		}
	}
}
